﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HotelWebservice;
using HotelWebservice.HotelWebservice;
using System.Data;



public partial class editroomEnv : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[QueryStrings.Uid] == null)
        {
            Response.Redirect("login3.aspx");
        }

        if (Request.QueryString.Count == 0)
        {
            this.Button1.Text = "没有传入jubacategoryId";

            return;
        }

        //if ( Request.QueryString.

        string jubacategoryId = Request.QueryString["id"].ToString();

        LoadCategoryRoomEnv(
            Cbank.Int.Parse(Session[QueryStrings.Uid])
            , Cbank.Int.Parse(jubacategoryId)
            );
    }


    RoomEnv RoomEnv
    {
        get
        {


            //todo: 取值tv取不到

            RoomEnv re = new RoomEnv();

            re.电视 = true;
            return re;



            re.电视 = Cbank.Bool.Parse(this.Request.Form["TV"].ToString());
            re.暖气 = Cbank.Bool.Parse(this.Request.Form["indoorFireplace"].ToString());

            re.门卫 = Cbank.Bool.Parse(this.Request.Form["doorman"].ToString());
            re.有线电视 = Cbank.Bool.Parse(this.Request.Form["cableTV"].ToString());
            re.电梯 = Cbank.Bool.Parse(this.Request.Form["elevatorInBuilding"].ToString());
            re.对讲门禁 = Cbank.Bool.Parse(this.Request.Form["intercom"].ToString());
            re.上网宽带 = Cbank.Bool.Parse(this.Request.Form["internet"].ToString());
            re.厨房 = Cbank.Bool.Parse(this.Request.Form["kitchen"].ToString());
            re.超市 = Cbank.Bool.Parse(this.Request.Form["supermarket"].ToString());
            re.电冰箱 = Cbank.Bool.Parse(this.Request.Form["icebox"].ToString());
            re.热水24小时 = Cbank.Bool.Parse(this.Request.Form["hotwater24"].ToString());
            re.银行 = Cbank.Bool.Parse(this.Request.Form["bank"].ToString());
            re.洗衣机 = Cbank.Bool.Parse(this.Request.Form["washer"].ToString());
            re.淋浴 = Cbank.Bool.Parse(this.Request.Form["shower"].ToString());
            re.饲养宠物 = Cbank.Bool.Parse(this.Request.Form["petsAllowed"].ToString());

            re.空调 = Cbank.Bool.Parse(this.Request.Form["airConditioning"].ToString());
            re.热水浴缸 = Cbank.Bool.Parse(this.Request.Form["hotTub"].ToString());
            re.吸烟 = Cbank.Bool.Parse(this.Request.Form["smokingAllowed"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            re.发票 = Cbank.Bool.Parse(this.Request.Form["taxFree"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());
            //re.电视 = Cbank.Bool.Parse(this.Request.Form["tv"].ToString());


            re.发票收费 = Cbank.Bool.Parse(this.Request.Form["taxCash"].ToString());

            

            //ri.床数 = Cbank.Int.Parse(this.Request.Form["beds"].ToString());

            return re;
        }

        set
        {
            //this.Request.Form["tv"] = "true";

            RoomEnv re = value;
            //todo:把re的值，都给赋到html控件里面去

            //document.getElementByID("控件ID").value="要赋的值"
            //Page.ClientScript.
            //                 2年前   yuji163sk : 
            //或者这样: 
            //前台: 
            //<input type="text" Text="<%=textvalue%>"/> 
            //后台: 
            //public string textvalue=string.Empty; 
            //textvalue="要赋的值";

            //在页面注册一段脚本 .page.clintscript.RegisterStartupScript（）脚本内容是给html控件赋值。ok

            //Page.ClientScript.RegisterStartupScript(
        }
    }


    int JubaId;
    int JubaCategoryId;


    void LoadCategoryRoomEnv(int jubaid, int jubacategoryId)
    {

        RoomEnvReturn enr = Hs.Juba_Category_Load_RoomEnv(jubaid, jubacategoryId);
        this.JubaId = jubaid;
        this.JubaCategoryId = jubacategoryId;
        this.RoomEnv = enr.RoomEnv;

    }


    protected void Button1_Click(object sender, EventArgs e)
    {
       // save env

        

    
    }

    void SaveRoomEnv(
        int JubaId
        ,int JubaCategoryId
        ,RoomEnv re

        )
    {

        Hs.Juba_Category_Edit_RoomEnv(
            re
            , JubaId
            , JubaCategoryId
            , Hs.adminpass
            );
    }






    Hs hs;
    Hs Hs
    {
        get
        {
            if (hs == null)
            {
                hs = new Hs();
            }
            return hs;
        }
    }


    protected void Button1_Click1(object sender, EventArgs e)
    {
        SaveRoomEnv(
            this.JubaId
            , this.JubaCategoryId
            , RoomEnv
            );

        this.Button1.Text = "保存成功" ;
        this.Button1.Enabled = false;


        this.Button2.Enabled = true;

    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("uploadRoomPic.aspx?Id=" + JubaCategoryId.ToString());
    }
}